#ifndef ODN_MODELBIT_H
#define ODN_MODELBIT_H

#include <opal\opal.h>
#include <ogre\Ogre.h>

#include "ODN_Maths.h"

namespace ouden {

class CModelBit
{
	public:
		CModelBit(opal::Solid* pSolid, Ogre::Node* pNode);
		virtual ~CModelBit();
		
		opal::Solid* 		getSolid() 			{ return m_pSolid; }
		Ogre::Node* 		getNode() 			{ return m_pNode; }
		
		//Ensures the solid and the node stay together
		//Called by parent model entity
		//TODO: Code this
		void update()
		{
			
			m_pNode->setPosition(toOgreVector(m_pSolid->getPosition()));
			
			opal::Point3r pos = m_pSolid->getPosition();
			opal::Quaternion quat = m_pSolid->getQuaternion();
			m_pNode->setPosition((Ogre::Real)pos[0], (Ogre::Real)pos[1], 
				(Ogre::Real)pos[2]);
			quat.normalize();
			m_pNode->setOrientation((Ogre::Real)quat[0], 
				(Ogre::Real)quat[1], (Ogre::Real)quat[2], 
				(Ogre::Real)quat[3]);
			
		}
		
	protected:
	
	private:
		
		//Physical and graphical representations
		opal::Solid* 		m_pSolid;
		Ogre::Node* 		m_pNode;
		
};

} //namespace ouden

#endif // ODN_MODELBIT_H
